home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / cp2dekit / h / binfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-29  |  6.2 KB  |  153 lines

  1. //***************************************************************************
  2. //
  3. // this file is (c) '94-'96 Niklas Beisert
  4. //
  5. // this file is part of the cubic player development kit.
  6. // you may only use/modify/spread this file under the terms stated
  7. // in the cubic player development kit accompanying documentation.
  8. //
  9. //***************************************************************************
  10.  
  11. #ifndef __BINFILE_H
  12. #define __BINFILE_H
  13.  
  14. #ifdef getc
  15.   #undef getc
  16. #endif
  17. #ifdef putc
  18.   #undef putc
  19. #endif
  20.  
  21. class binfile
  22. {
  23. protected:
  24.   int mode;
  25.   long filepos;
  26.   long filelen;
  27.  
  28. public:
  29.   enum { canread=1, canwrite=2, canseek=4, canchsize=8 };
  30.   int getmode() { return mode; }
  31.  
  32.   binfile();
  33.   virtual ~binfile();
  34.  
  35.   virtual void close();
  36.  
  37. // abstract functions
  38.   virtual long read(void *buf, long len);
  39.   virtual long write(const void *buf, long len);
  40.   virtual long seek(long pos);
  41.   virtual long chsize(long pos);
  42.  
  43. // predefined functions
  44.   virtual int eread(void *buf, long len);
  45.   virtual int ewrite(const void *buf, long len);
  46.   virtual long seekcur(long pos);
  47.   virtual long seekend(long pos);
  48.   virtual long tell();
  49.   virtual long length();
  50.   virtual int eof();
  51.  
  52. // basic types io
  53.   virtual char getc();
  54.   virtual short gets();
  55.   virtual long getl();
  56.   virtual binfile &putc(char c);
  57.   virtual binfile &puts(short s);
  58.   virtual binfile &putl(long l);
  59.   virtual char egetc(int &stat);
  60.   virtual short egets(int &stat);
  61.   virtual long egetl(int &stat);
  62.   virtual int eputc(char c);
  63.   virtual int eputs(short s);
  64.   virtual int eputl(long l);
  65.  
  66. // operators
  67.   binfile &operator [](long pos) { seek(pos); return *this; }
  68.  
  69. // derived types io
  70.   signed char getsc() { return getc(); }
  71.   unsigned char getuc() { return getc(); }
  72.   signed short getss() { return gets(); }
  73.   unsigned short getus() { return gets(); }
  74.   signed long getsl() { return getl(); }
  75.   unsigned long getul() { return getl(); }
  76.   binfile &putsc(signed char c) { return putc(c); }
  77.   binfile &putuc(unsigned char c) { return putc(c); }
  78.   binfile &putss(signed short s) { return puts(s); }
  79.   binfile &putus(unsigned short s) { return puts(s); }
  80.   binfile &putsl(signed long l) { return putl(l); }
  81.   binfile &putul(unsigned long l) { return putl(l); }
  82.   signed char egetsc(int &stat) { return egetc(stat); }
  83.   unsigned char egetuc(int &stat) { return egetc(stat); }
  84.   signed short egetss(int &stat) { return egets(stat); }
  85.   unsigned short egetus(int &stat) { return egets(stat); }
  86.   signed long egetsl(int &stat) { return egetl(stat); }
  87.   unsigned long egetul(int &stat) { return egetl(stat); }
  88.   int eputsc(signed char c) { return eputc(c); }
  89.   int eputuc(unsigned char c) { return eputc(c); }
  90.   int eputss(signed short s) { return eputs(s); }
  91.   int eputus(unsigned short s) { return eputs(s); }
  92.   int eputsl(signed long l) { return eputl(l); }
  93.   int eputul(unsigned long l) { return eputl(l); }
  94. };
  95.  
  96. inline long read(binfile &f, void *buf, long len) { return f.read(buf, len); }
  97. inline long write(binfile &f, void *buf, long len) { return f.write(buf, len); }
  98. inline int eread(binfile &f, void *buf, long len) { return f.eread(buf, len); }
  99. inline int ewrite(binfile &f, void *buf, long len) { return f.ewrite(buf, len); }
  100. inline long seek(binfile &f, long pos) { return f.seek(pos); }
  101. inline long seekcur(binfile &f, long pos) { return f.seekcur(pos); }
  102. inline long seekend(binfile &f, long pos) { return f.seekend(pos); }
  103. inline long chsize(binfile &f, long pos) { return f.chsize(pos); }
  104. inline long tell(binfile &f) { return f.tell(); }
  105. inline long length(binfile &f) { return f.length(); }
  106. inline int eof(binfile &f) { return f.eof(); }
  107.  
  108. inline char getc(binfile &f) { return f.getc(); }
  109. inline signed char getsc(binfile &f) { return f.getsc(); }
  110. inline unsigned char getuc(binfile &f) { return f.getuc(); }
  111. inline short gets(binfile &f) { return f.gets(); }
  112. inline signed short getss(binfile &f) { return f.getss(); }
  113. inline unsigned short getus(binfile &f) { return f.getus(); }
  114. inline long getl(binfile &f) { return f.getl(); }
  115. inline signed long getsl(binfile &f) { return f.getsl(); }
  116. inline unsigned long getul(binfile &f) { return f.getul(); }
  117. inline binfile &putc(binfile &f, char c) { return f.putc(c); }
  118. inline binfile &putsc(binfile &f, signed char c) { return f.putsc(c); }
  119. inline binfile &putuc(binfile &f, unsigned char c) { return f.putuc(c); }
  120. inline binfile &puts(binfile &f, short s) { return f.puts(s); }
  121. inline binfile &putss(binfile &f, signed short s) { return f.putss(s); }
  122. inline binfile &putus(binfile &f, unsigned short s) { return f.putus(s); }
  123. inline binfile &putl(binfile &f, long l) { return f.putl(l); }
  124. inline binfile &putsl(binfile &f, signed long l) { return f.putsl(l); }
  125. inline binfile &putul(binfile &f, unsigned long l) { return f.putul(l); }
  126. inline char egetc(binfile &f, int &stat) { return f.egetc(stat); }
  127. inline signed char egetsc(binfile &f, int &stat) { return f.egetsc(stat); }
  128. inline unsigned char egetuc(binfile &f, int &stat) { return f.egetuc(stat); }
  129. inline short egets(binfile &f, int &stat) { return f.egets(stat); }
  130. inline signed short egetss(binfile &f, int &stat) { return f.egetss(stat); }
  131. inline unsigned short egetus(binfile &f, int &stat) { return f.egetus(stat); }
  132. inline long egetl(binfile &f, int &stat) { return f.egetl(stat); }
  133. inline signed long egetsl(binfile &f, int &stat) { return f.egetsl(stat); }
  134. inline unsigned long egetul(binfile &f, int &stat) { return f.egetul(stat); }
  135. inline int eputc(binfile &f, char c) { return f.eputc(c); }
  136. inline int eputsc(binfile &f, signed char c) { return f.eputsc(c); }
  137. inline int eputuc(binfile &f, unsigned char c) { return f.eputuc(c); }
  138. inline int eputs(binfile &f, short s) { return f.eputs(s); }
  139. inline int eputss(binfile &f, signed short s) { return f.eputss(s); }
  140. inline int eputus(binfile &f, unsigned short s) { return f.eputus(s); }
  141. inline int eputl(binfile &f, long l) { return f.eputl(l); }
  142. inline int eputsl(binfile &f, signed long l) { return f.eputsl(l); }
  143. inline int eputul(binfile &f, unsigned long l) { return f.eputul(l); }
  144.  
  145. #include "binfstd.h"
  146. #include "binfdel.h"
  147. #include "binfcach.h"
  148. #include "binfmem.h"
  149. #include "binfarc.h"
  150. #include "binfpak.h"
  151.  
  152. #endif
  153.